home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 15 / CU Amiga Magazine's Super CD-ROM 15 (1997)(EMAP Images)(GB)[!][issue 1997-10].iso / CUCD / Graphics / Ghostscript / source / gxcindex.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-20  |  3.4 KB  |  97 lines

  1. /* Copyright (C) 1995, 1996 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of Aladdin Ghostscript.
  4.   
  5.   Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  6.   or distributor accepts any responsibility for the consequences of using it,
  7.   or for whether it serves any particular purpose or works at all, unless he
  8.   or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  9.   License (the "License") for full details.
  10.   
  11.   Every copy of Aladdin Ghostscript must include a copy of the License,
  12.   normally in a plain ASCII text file named PUBLIC.  The License grants you
  13.   the right to copy, modify and redistribute Aladdin Ghostscript, but only
  14.   under certain conditions described in the License.  Among other things, the
  15.   License requires that the copyright notice and this notice be preserved on
  16.   all copies.
  17. */
  18.  
  19. /* gxcindex.h */
  20. /* Define the device color index type and macros */
  21. /* Requires gxbitmap.h. */
  22.  
  23. #ifndef gxcindex_INCLUDED
  24. #  define gxcindex_INCLUDED
  25.  
  26. /*
  27.  * Internally, a (pure) device color is represented by opaque values of
  28.  * type gx_color_index, which are tied to the specific device.  The driver
  29.  * maps between these values and RGB[alpha] or CMYK values.  In this way,
  30.  * the driver can convert RGB values to its most natural color representation,
  31.  * and have the graphics library cache the result.
  32.  */
  33.  
  34. /* Define the type for device color indices. */
  35. typedef unsigned long gx_color_index;
  36. #define arch_log2_sizeof_color_index arch_log2_sizeof_long
  37. #define arch_sizeof_color_index arch_sizeof_long
  38.  
  39. /* Define the 'transparent' color index. */
  40. #define gx_no_color_index_value (-1)    /* no cast -> can be used in #if */
  41.  
  42. /* The SGI C compiler provided with Irix 5.2 gives error messages */
  43. /* if we use the proper definition of gx_no_color_index: */
  44. /*#define gx_no_color_index ((gx_color_index)gx_no_color_index_value)*/
  45. /* Instead, we must spell out the typedef: */
  46. #define gx_no_color_index ((unsigned long)gx_no_color_index_value)
  47.  
  48. /*
  49.  * Define macros for accumulating a scan line of a colored image.
  50.  * The usage is as follows:
  51.  *    declare_line_accum(line, bpp, xo);
  52.  *    for ( x = xo; x < xe; ++x )
  53.  *      {    << compute color at x >>
  54.  *        line_accum(color, bpp);
  55.  *      }
  56.  *    line_accum_copy(dev, line, bpp, xo, xe, raster, y);
  57.  * This code must be enclosed in { }, since declare_line_accum declares
  58.  * variables.
  59.  *
  60.  * Note that declare_line_accum declares the variables l_dst, l_bits, l_shift,
  61.  * and l_xprev.  Other code in the loop may use these variables.
  62.  */
  63. #define declare_line_accum(line, bpp, xo)\
  64.     byte *l_dst = (line);\
  65.     uint l_bits = 0;\
  66.     int l_shift = 8 - (bpp);\
  67.     int l_xprev = (xo)
  68. #define line_accum(color, bpp)\
  69.     switch ( (bpp) >> 3 )\
  70.       {\
  71.       case 0:\
  72.         l_bits += (uint)((color) << l_shift);\
  73.         if ( (l_shift -= (bpp)) < 0 )\
  74.           *l_dst++ = (byte)l_bits, l_bits = 0,\
  75.           l_shift += 8;\
  76.         break;\
  77.       case 4: *l_dst++ = (byte)((color) >> 24);\
  78.       case 3: *l_dst++ = (byte)((color) >> 16);\
  79.       case 2: *l_dst++ = (byte)((color) >> 8);\
  80.       case 1: *l_dst++ = (byte)(color);\
  81.       }
  82. #define line_accum_store(bpp)\
  83.     if ( l_shift != 8 - (bpp) )\
  84.       *l_dst = (byte)l_bits
  85. #define line_accum_copy(dev, line, bpp, xo, xe, raster, y)\
  86.     if ( (xe) > l_xprev )\
  87.       { int code;\
  88.         line_accum_store(bpp);\
  89.         code = (*dev_proc(dev, copy_color))\
  90.           (dev, line, l_xprev - (xo), raster,\
  91.            gx_no_bitmap_id, l_xprev, y, (xe) - l_xprev, 1);\
  92.         if ( code < 0 )\
  93.           return code;\
  94.       }
  95.  
  96. #endif                    /* gxcindex_INCLUDED */
  97.